home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Events
/
Tick.h
< prev
Wrap
Text File
|
2000-06-23
|
1KB
|
47 lines
// Tick.h
#ifndef Tick_h
#define Tick_h
#ifndef Integers_h
#include "Integers.h"
#endif
#include <Events.h>
class Tick
{
private:
int32 time;
public:
explicit Tick( uint32 t ) : time( int32( t ) ) {}
int32 Time() const { return time; }
static Tick Now() { return Tick( TickCount() ); }
void operator+=( int32 d ) { time += d; }
void operator-=( int32 d ) { time -= d; }
const Tick operator+( int32 d ) const { return Tick( uint32( time + d ) ); }
const Tick operator-( int32 d ) const { return Tick( uint32( time - d ) ); }
int32 operator-( Tick t ) const { return time - t.time; }
bool operator==( Tick t ) const { return time == t.time; }
bool operator!=( Tick t ) const { return time != t.time; }
// We avoid the ordinary comparisons here so that we
// can compare times (locally) around the time when
// TickCount overflows.
bool operator<=( Tick t ) const { return time - t.time <= 0; }
bool operator>=( Tick t ) const { return time - t.time >= 0; }
bool operator<( Tick t ) const { return time - t.time < 0; }
bool operator>( Tick t ) const { return time - t.time > 0; }
void WaitFor() const;
};
#endif